﻿<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>教务管理系统 - 教师首页</title>
    <link href="${pageContext.request.contextPath}/resources/bootstrap5/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons - 本地版本 -->
    <link href="${pageContext.request.contextPath}/resources/bootstrap-icons/1.11.3/bootstrap-icons.css" rel="stylesheet">
    <!-- Bootstrap Icons - 备用CDN -->
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
    <!-- 第二个备用CDN -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
    <style>
        body {
            font-family: "Microsoft YaHei", sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
        }

        .header {
            background-color: #1976d2;
            color: white;
            padding: 10px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            position: fixed;
            width: 100%;
            top: 0;
            z-index: 1000;
        }
        
        .header-left {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .header h2 {
            margin: 0;
            font-size: 1.5rem;
            display: flex;
            align-items: center;
        }

        .header h2 img {
            height: 36px;
            margin-right: 10px;
        }

        .header .breadcrumb {
            margin: 0;
            background: transparent;
            color: white;
        }

        .header .breadcrumb a {
            color: rgba(255,255,255,0.8);
            text-decoration: none;
        }

        .header .breadcrumb a:hover {
            color: white;
        }

        .header .breadcrumb-item.active {
            color: white;
        }

        .header .breadcrumb-item+.breadcrumb-item::before {
            color: rgba(255,255,255,0.6);
        }

        /* 侧边栏样式 */
        .sidebar {
            position: fixed;
            top: 56px;
            left: 0;
            bottom: 0;
            width: 250px;
            background-color: white;
            box-shadow: 2px 0 5px rgba(0,0,0,0.1);
            overflow-y: auto;
            z-index: 100;
            padding-top: 20px;
        }

        .sidebar-menu {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .sidebar-menu > li {
            margin-bottom: 5px;
        }

        .sidebar-menu > li > a {
            display: flex;
            align-items: center;
            padding: 12px 20px;
            color: #333;
            text-decoration: none;
            transition: all 0.3s;
            border-left: 3px solid transparent;
        }

        .sidebar-menu > li > a:hover {
            background-color: #f0f0f0;
            border-left-color: #1976d2;
        }

        .sidebar-menu > li > a.active {
            background-color: #e3f2fd;
            border-left-color: #1976d2;
            color: #1976d2;
        }

        .sidebar-menu > li > a i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
            font-size: 1.1rem;
        }

        .sidebar-submenu {
            list-style: none;
            padding-left: 53px;
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
        }

        .sidebar-menu > li.open .sidebar-submenu {
            max-height: 500px;
        }

        .sidebar-submenu > li > a {
            display: block;
            padding: 8px 0;
            color: #666;
            text-decoration: none;
            transition: all 0.3s;
        }

        .sidebar-submenu > li > a:hover {
            color: #1976d2;
        }

        .sidebar-submenu > li > a.active {
            color: #1976d2;
            font-weight: 500;
        }

        /* 内容区样式 */
        .content {
            margin-left: 250px;
            padding: 76px 20px 20px;
        }
        
        /* 用户下拉菜单样式 */
        .header-user {
            display: flex;
            align-items: center;
            position: relative;
        }
        .header-user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            margin-right: 8px;
            object-fit: cover;
            background: #fff;
            cursor: pointer;
            transition: transform 0.2s;
        }
        .header-user-avatar:hover {
            transform: scale(1.1);
        }
        .header-user-name {
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            font-family: 'Microsoft YaHei', Arial, sans-serif;
        }
        .user-dropdown {
            position: absolute;
            top: 100%;
            right: 0;
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
            min-width: 160px;
            z-index: 1001;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.3s ease;
            margin-top: 8px;
        }
        .user-dropdown.show {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        .user-dropdown::before {
            content: '';
            position: absolute;
            top: -6px;
            right: 20px;
            width: 12px;
            height: 12px;
            background: #fff;
            transform: rotate(45deg);
            box-shadow: -2px -2px 4px rgba(0,0,0,0.1);
        }
        .user-dropdown-item {
            display: flex;
            align-items: center;
            padding: 12px 16px;
            color: #333;
            text-decoration: none;
            transition: background 0.2s;
            border-bottom: 1px solid #f0f0f0;
            font-family: 'Microsoft YaHei', Arial, sans-serif;
        }
        .user-dropdown-item:last-child {
            border-bottom: none;
        }
        .user-dropdown-item:hover {
            background: #f8f9fa;
            color: #1976d2;
        }
        .user-dropdown-item i {
            margin-right: 8px;
            width: 16px;
            text-align: center;
        }

        .card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            margin-bottom: 20px;
            overflow: hidden;
            height: 100%;
        }

        .card-header {
            padding: 15px 20px;
            background-color: white;
            border-bottom: 1px solid #eee;
            font-weight: 600;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .card-body {
            padding: 20px;
            overflow-y: auto;
            max-height: 400px;
        }

        .welcome-card {
            background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
            color: #fff;
            padding: 32px;
            text-align: center;
            border-radius: 8px;
            margin-bottom: 32px;
        }
        
        .welcome-card h2 {
            margin-bottom: 16px;
            font-weight: bold;
        }
        
        .welcome-card p {
            font-size: 1.1rem;
            opacity: 0.9;
            margin: 0;
        }

        .quick-actions {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 32px;
        }

        .quick-action-item {
            background: #fff;
            border-radius: 8px;
            padding: 24px;
            text-align: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            text-decoration: none;
            color: inherit;
            border: 1px solid #f0f0f0;
        }

        .quick-action-item:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 24px rgba(0,0,0,0.12);
            text-decoration: none;
            color: inherit;
        }

        .quick-action-icon {
            width: 64px;
            height: 64px;
            margin: 0 auto 16px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.8rem;
            color: #fff;
        }

        .icon-courses {
            background: linear-gradient(135deg, #1976d2, #1565c0);
        }

        .icon-grades {
            background: linear-gradient(135deg, #388e3c, #2e7d32);
        }

        .icon-attendance {
            background: linear-gradient(135deg, #f57c00, #ef6c00);
        }

        .icon-homework {
            background: linear-gradient(135deg, #7b1fa2, #6a1b9a);
        }

        .icon-evaluation {
            background: linear-gradient(135deg, #d32f2f, #c62828);
        }

        .icon-leave {
            background: linear-gradient(135deg, #795548, #6d4c41);
        }

        .quick-action-title {
            font-size: 1.1rem;
            font-weight: 600;
            margin-bottom: 8px;
            color: #333;
        }

        .quick-action-desc {
            font-size: 0.9rem;
            color: #666;
            margin: 0;
        }

        .stats-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .stat-card {
            background: #fff;
            border-radius: 8px;
            padding: 20px;
            text-align: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            border: 1px solid #f0f0f0;
        }

        .stat-number {
            font-size: 2rem;
            font-weight: bold;
            color: #1976d2;
            margin-bottom: 8px;
        }

        .stat-label {
            color: #666;
            font-size: 0.9rem;
        }

        .notification-list {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .notification-item {
            padding: 15px 0;
            border-bottom: 1px solid #eee;
            display: flex;
        }

        .notification-item:last-child {
            border-bottom: none;
        }

        .notification-dot {
            width: 12px;
            height: 12px;
            background-color: #1976d2;
            border-radius: 50%;
            margin-top: 5px;
            margin-right: 15px;
            flex-shrink: 0;
        }

        .notification-content {
            flex-grow: 1;
        }

        .notification-title {
            margin: 0 0 5px;
            font-weight: 500;
            display: flex;
            justify-content: space-between;
        }

        .notification-date {
            color: #888;
            font-size: 0.85rem;
            font-weight: normal;
        }

        .notification-type {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 0.75rem;
            margin-left: 10px;
        }

        .type-1 {
            background-color: #e3f2fd;
            color: #1976d2;
        }

        .type-2 {
            background-color: #fff8e1;
            color: #ff9800;
        }

        .empty-message {
            text-align: center;
            padding: 30px;
            color: #888;
            font-style: italic;
        }

        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
                transition: transform 0.3s;
            }

            .sidebar.active {
                transform: translateX(0);
            }

            .content {
                margin-left: 0;
            }

            .stats-row,
            .quick-actions {
                grid-template-columns: 1fr;
                gap: 15px;
            }
        }
    </style>
</head>
<body>
    <!-- 头部导航栏 -->
    <div class="header">
        <div class="header-left">
            <h2><img src="${pageContext.request.contextPath}/resources/images/logo.png" alt="Logo"> 教务管理系统</h2>
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item active">教师首页</li>
                </ol>
            </nav>
        </div>
        
        <!-- 用户下拉菜单 -->
        <div class="header-user" id="userDropdownContainer">
            <img src="${pageContext.request.contextPath}/resources/images/baimao.png" class="header-user-avatar" alt="用户头像" id="userAvatar">
            <span class="header-user-name" id="userName">
                <c:choose>
                    <c:when test="${not empty currentTeacher and not empty currentTeacher.user and not empty currentTeacher.user.realName}">
                        ${currentTeacher.user.realName}
                    </c:when>
                    <c:when test="${not empty sessionScope.loggedInUser and not empty sessionScope.loggedInUser.realName}">
                        ${sessionScope.loggedInUser.realName}
                    </c:when>
                    <c:when test="${not empty sessionScope.loggedInUser and not empty sessionScope.loggedInUser.username}">
                        ${sessionScope.loggedInUser.username}
                    </c:when>
                    <c:otherwise>
                        教师
                    </c:otherwise>
                </c:choose>
            </span>
            <div class="user-dropdown" id="userDropdown">
                <a href="#" class="user-dropdown-item" onclick="showProfileModal()">
                    <i class="bi bi-person-circle"></i>
                    个人信息
                </a>
                <a href="${pageContext.request.contextPath}/teacher/changePassword" class="user-dropdown-item">
                    <i class="bi bi-key"></i>
                    修改密码
                </a>
                <a href="${pageContext.request.contextPath}/user/logout" class="user-dropdown-item">
                    <i class="bi bi-box-arrow-right"></i>
                    退出系统
                </a>
            </div>
        </div>
    </div>

    <!-- 侧边栏 -->
    <div class="sidebar">
        <ul class="sidebar-menu">
            <li>
                <a href="${pageContext.request.contextPath}/teacher/home" class="active">
                    <i class="bi bi-house-door"></i> 教师首页
                </a>
            </li>
            <li>
                <a href="#" class="has-submenu">
                    <i class="bi bi-megaphone"></i> 信息公告
                </a>
                <ul class="sidebar-submenu">
                    <li><a href="${pageContext.request.contextPath}/teacher/notifications/academic">教务通知</a></li>
                    <li><a href="${pageContext.request.contextPath}/teacher/notifications/exam">考试安排</a></li>
                    <li><a href="${pageContext.request.contextPath}/teacher/notifications/classroom">教学安排</a></li>
                </ul>
            </li>
            <li>
                <a href="#" class="has-submenu">
                    <i class="bi bi-book"></i> 教学管理
                </a>
                <ul class="sidebar-submenu">
                    <li><a href="${pageContext.request.contextPath}/teacher/courses">我的课程</a></li>
                    <li><a href="${pageContext.request.contextPath}/teacher/course-students">选课学生</a></li>
                    <li><a href="${pageContext.request.contextPath}/teacher/homework">作业管理</a></li>
                    <li><a href="${pageContext.request.contextPath}/teacher/grades">成绩管理</a></li>
                    <li><a href="${pageContext.request.contextPath}/teacher/attendance">考勤管理</a></li>
                </ul>
            </li>
            <li>
                <a href="#" class="has-submenu">
                    <i class="bi bi-person-check"></i> 学生管理
                </a>
                <ul class="sidebar-submenu">
                    <li><a href="${pageContext.request.contextPath}/teacher/evaluation">教学评价</a></li>
                    <li><a href="${pageContext.request.contextPath}/teacher/leave">请假审批</a></li>
                </ul>
            </li>
            <li>
                <a href="${pageContext.request.contextPath}/user/logout">
                    <i class="bi bi-box-arrow-right"></i> 退出系统
                </a>
            </li>
        </ul>
    </div>

    <!-- 主要内容区 -->
    <div class="content">
        <!-- 欢迎卡片 -->
        <div class="welcome-card">
            <h2>
                <i class="bi bi-hand-thumbs-up me-2"></i>
                欢迎回来，
                <c:choose>
                    <c:when test="${not empty sessionScope.loggedInUser and not empty sessionScope.loggedInUser.realName}">
                        ${sessionScope.loggedInUser.realName} 老师
                    </c:when>
                    <c:otherwise>
                        尊敬的老师
                    </c:otherwise>
                </c:choose>
            </h2>
            <p>今天又是充满活力的一天，让我们一起为学生们创造更好的学习体验吧！</p>
        </div>

        <!-- 快捷功能 -->
        <h4 class="mb-4"><i class="bi bi-lightning-charge me-2"></i>快捷功能</h4>
        <div class="quick-actions">
            <a href="${pageContext.request.contextPath}/teacher/courses" class="quick-action-item">
                <div class="quick-action-icon icon-courses">
                    <i class="bi bi-book"></i>
                </div>
                <div class="quick-action-title">我的课程</div>
                <div class="quick-action-desc">管理您的教学课程</div>
            </a>
            <a href="${pageContext.request.contextPath}/teacher/homework" class="quick-action-item">
                <div class="quick-action-icon icon-homework">
                    <i class="bi bi-file-earmark-text"></i>
                </div>
                <div class="quick-action-title">作业管理</div>
                <div class="quick-action-desc">布置和批改作业</div>
            </a>
            <a href="${pageContext.request.contextPath}/teacher/grades" class="quick-action-item">
                <div class="quick-action-icon icon-grades">
                    <i class="bi bi-clipboard-data"></i>
                </div>
                <div class="quick-action-title">成绩管理</div>
                <div class="quick-action-desc">录入和查看成绩</div>
            </a>
            <a href="${pageContext.request.contextPath}/teacher/attendance" class="quick-action-item">
                <div class="quick-action-icon icon-attendance">
                    <i class="bi bi-calendar-check"></i>
                </div>
                <div class="quick-action-title">考勤管理</div>
                <div class="quick-action-desc">管理学生考勤</div>
            </a>
            <a href="${pageContext.request.contextPath}/teacher/evaluation" class="quick-action-item">
                <div class="quick-action-icon icon-evaluation">
                    <i class="bi bi-star"></i>
                </div>
                <div class="quick-action-title">教学评价</div>
                <div class="quick-action-desc">查看学生评教</div>
            </a>
            <a href="${pageContext.request.contextPath}/teacher/leave" class="quick-action-item">
                <div class="quick-action-icon icon-leave">
                    <i class="bi bi-calendar-x"></i>
                </div>
                <div class="quick-action-title">请假审批</div>
                <div class="quick-action-desc">审批学生请假申请</div>
            </a>
        </div>

        <!-- 通知信息 -->
        <div class="row">
            <div class="col-lg-6">
                <div class="card">
                    <div class="card-header">
                        <i class="bi bi-megaphone me-2"></i>教务通知
                        <a href="${pageContext.request.contextPath}/teacher/notifications/academic" class="btn btn-sm btn-primary ms-auto">查看更多</a>
                    </div>
                    <div class="card-body">
                        <c:choose>
                            <c:when test="${not empty academicNotifications}">
                                <ul class="notification-list">
                                    <c:forEach var="notification" items="${academicNotifications}" varStatus="status">
                                        <c:if test="${status.index < 3}">
                                            <li class="notification-item">
                                                <div class="notification-dot"></div>
                                                <div class="notification-content">
                                                    <div class="notification-title">
                                                        <c:out value="${notification.title}"/>
                                                        <span class="notification-type type-1">教务</span>
                                                        <small class="notification-date">
                                                            <c:choose>
                                                                <c:when test="${not empty notification.createTime}">
                                                                    ${notification.createTime.substring(0, 10)}
                                                                </c:when>
                                                                <c:otherwise>
                                                                    ${notification.createTime}
                                                                </c:otherwise>
                                                            </c:choose>
                                                        </small>
                                                    </div>
                                                </div>
                                            </li>
                                        </c:if>
                                    </c:forEach>
                                </ul>
                            </c:when>
                            <c:otherwise>
                                <div class="empty-message">
                                    <i class="bi bi-inbox"></i>
                                    <p>暂无教务通知</p>
                                </div>
                            </c:otherwise>
                        </c:choose>
                    </div>
                </div>
            </div>
            <div class="col-lg-6">
                <div class="card">
                    <div class="card-header">
                        <i class="bi bi-calendar-event me-2"></i>考试安排
                        <a href="${pageContext.request.contextPath}/teacher/notifications/exam" class="btn btn-sm btn-primary ms-auto">查看更多</a>
                    </div>
                    <div class="card-body">
                        <c:choose>
                            <c:when test="${not empty examNotifications}">
                                <ul class="notification-list">
                                    <c:forEach var="notification" items="${examNotifications}" varStatus="status">
                                        <c:if test="${status.index < 3}">
                                            <li class="notification-item">
                                                <div class="notification-dot"></div>
                                                <div class="notification-content">
                                                    <div class="notification-title">
                                                        <c:out value="${notification.title}"/>
                                                        <span class="notification-type type-2">考试</span>
                                                        <small class="notification-date">
                                                            <c:choose>
                                                                <c:when test="${not empty notification.createTime}">
                                                                    ${notification.createTime.substring(0, 10)}
                                                                </c:when>
                                                                <c:otherwise>
                                                                    ${notification.createTime}
                                                                </c:otherwise>
                                                            </c:choose>
                                                        </small>
                                                    </div>
                                                </div>
                                            </li>
                                        </c:if>
                                    </c:forEach>
                                </ul>
                            </c:when>
                            <c:otherwise>
                                <div class="empty-message">
                                    <i class="bi bi-calendar-x"></i>
                                    <p>暂无考试安排</p>
                                </div>
                            </c:otherwise>
                        </c:choose>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="${pageContext.request.contextPath}/resources/bootstrap5/js/bootstrap.bundle.min.js"></script>
    <script>
        // 用户下拉菜单
        document.getElementById('userDropdownContainer').addEventListener('click', function(e) {
            e.stopPropagation();
            const dropdown = document.getElementById('userDropdown');
            dropdown.classList.toggle('show');
        });

        // 点击其他地方关闭下拉菜单
        document.addEventListener('click', function() {
            const dropdown = document.getElementById('userDropdown');
            dropdown.classList.remove('show');
        });

        // 侧边栏子菜单切换
        function toggleSubmenu(element) {
            const parent = element.parentElement;
            const submenu = parent.querySelector('.sidebar-submenu');
            
            // 关闭其他打开的子菜单
            document.querySelectorAll('.sidebar-menu > li').forEach(li => {
                if (li !== parent) {
                    li.classList.remove('open');
                }
            });
            
            // 切换当前子菜单
            parent.classList.toggle('open');
        }

        // 页面加载完成后的初始化
        document.addEventListener('DOMContentLoaded', function() {
            // 为有子菜单的项目添加点击事件
            document.querySelectorAll('.has-submenu').forEach(item => {
                item.addEventListener('click', function(e) {
                    e.preventDefault();
                    toggleSubmenu(this);
                });
            });
        });
        
        // 显示个人信息模态框
        function showProfileModal() {
            const dropdown = document.getElementById('userDropdown');
            dropdown.classList.remove('show');
            
            alert('个人信息功能待开发');
        }
    </script>
</body>
</html> 


